# -*- coding:utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin

from .models import *


class ELOwtaxAdmin(admin.ModelAdmin):
    list_display = ["id", "get_entname", "cpwsid", "taxdepar", "tax_unpaid_amount", "pubdate"]
    list_display_links = ["get_entname", ]
    search_fields = ("^entid_id", "^REGNO",)

    def get_entname(self, obj):
        if obj.entid_id:
            the_ents = (ELPost.objects.filter(entid=obj.entid_id).values_list("ENTNAME", flat=True))
            if len(the_ents):
                return the_ents[0]
        return ""

    get_entname.short_description = "所属企业"


class ELUnnortaxAdmin(admin.ModelAdmin):
    list_display = ["id", "get_entname", "case_id_unnortax", "taxdepar", "pubdate"]
    list_display_links = ["get_entname", ]
    search_fields = ("^entid_id", "^REGNO",)

    def get_entname(self, obj):
        if obj.entid_id:
            the_ents = (ELPost.objects.filter(entid=obj.entid_id).values_list("ENTNAME", flat=True))
            if len(the_ents):
                return the_ents[0]
        return ""

    get_entname.short_description = "所属企业"


class ELUnoperaAdmin(admin.ModelAdmin):
    list_display = ["id", "get_entname", "case_id_unopera", "depar", "reason", "indate"]
    list_display_links = ["get_entname", ]
    search_fields = ("^entid_id", "^REGNO",)

    def get_entname(self, obj):
        if obj.entid_id:
            the_ents = (ELPost.objects.filter(entid=obj.entid_id).values_list("ENTNAME", flat=True))
            if len(the_ents):
                return the_ents[0]
        return ""

    get_entname.short_description = "所属企业"


class ELLawAidAdmin(admin.ModelAdmin):
    list_display = ["id", "get_entname", "case_id_aid", "aidcase_assior_ent", "amount", "pubdate"]
    list_display_links = ["get_entname", ]
    search_fields = ("^entid_id", "^REGNO",)

    def get_entname(self, obj):
        if obj.entid_id:
            the_ents = (ELPost.objects.filter(entid=obj.entid_id).values_list("ENTNAME", flat=True))
            if len(the_ents):
                return the_ents[0]
        return ""

    get_entname.short_description = "所属企业"


class ELLawSSAdmin(admin.ModelAdmin):
    list_display = ["id", "get_entname", "case_id_law", "case_type", "case_court", "case_parties", "pubdate"]
    list_display_links = ["get_entname", ]
    search_fields = ("^entid_id", "^REGNO",)

    def get_entname(self, obj):
        if obj.entid_id:
            the_ents = (ELPost.objects.filter(entid=obj.entid_id).values_list("ENTNAME", flat=True))
            if len(the_ents):
                return the_ents[0]
        return ""

    get_entname.short_description = "所属企业"


class ELCpwsAdmin(admin.ModelAdmin):
    list_display = ["id", "entid", "case_id_judg", "case_title", "judgdate", ]
    list_display_links = ["entid", ]
    search_fields = ("^entid_id", "^REGNO",)


class ELKtggAdmin(admin.ModelAdmin):
    list_display = ["id", "entid", "case_id_court", "court", "courdate", ]
    list_display_links = ["entid", ]
    search_fields = ("^entid_id", "^REGNO",)


class ELPartysAdmin(admin.ModelAdmin):
    list_display = ["id", "title", "nickname", "lawoffice", "status", ]
    list_display_links = ["title", ]
    search_fields = ("^title",)


class ELZxggAdmin(admin.ModelAdmin):
    list_display = ["id", "title", "pname", "court", "sorttime", ]
    list_display_links = ["title", ]
    search_fields = ("^title",)


class ELSxggAdmin(admin.ModelAdmin):
    list_display = ["id", "sxggid", "pname", "court", "sorttime", ]
    list_display_links = ["sxggid", ]
    search_fields = ("^sxggid", "^pname",)


class ELFyggAdmin(admin.ModelAdmin):
    list_display = ["id", "fyggid", "pname", "court", "sorttime", ]
    list_display_links = ["fyggid", ]
    search_fields = ("^fyggid", "^pname",)


class ELWdhmdAdmin(admin.ModelAdmin):
    list_display = ["id", "wdhmdid", "pname", "execourt", "sorttime", ]
    list_display_links = ["wdhmdid", ]
    search_fields = ("^wdhmdid", "^pname",)


class ELAjlcAdmin(admin.ModelAdmin):
    list_display = ["id", "pname", "member", "court", "sorttime", ]
    list_display_links = ["pname", ]
    search_fields = ("^pname",)


class ELbgtAdmin(admin.ModelAdmin):
    list_display = ["id", "pname", "partytype", "court", "sorttime", ]
    list_display_links = ["pname", ]
    search_fields = ("^pname",)


class ELEpbcfAdmin(admin.ModelAdmin):
    list_display = ["id", "epbcfid", "pname", "money", "punishorg", "sorttime", ]
    list_display_links = ["epbcfid", "pname", ]
    search_fields = ("^epbcfid", "^pname",)


class ELLawCreditAdmin(admin.ModelAdmin):
    list_display = ["id", "creditid", "pname", "credittype", "authority", "sorttime", ]
    list_display_links = ["creditid", "pname", ]
    search_fields = ("^creditid", "^pname",)


class ELAbstractAdmin(admin.ModelAdmin):
    list_display = ["id", "sorttime", "fee", "casecause", "court", "caf", ]
    list_display_links = ["sorttime", "fee", ]
    search_fields = ("^court",)


# admin.site.register(ELOwtax, ELOwtaxAdmin)
# admin.site.register(ELUnnortax, ELUnnortaxAdmin)
# admin.site.register(ELUnopera, ELUnoperaAdmin)
# admin.site.register(ELLawAid, ELLawAidAdmin)
# admin.site.register(ELLawSS, ELLawSSAdmin)
# admin.site.register(ELCpws, ELCpwsAdmin)
# admin.site.register(ELKtgg, ELKtggAdmin)
# admin.site.register(ELPartys, ELPartysAdmin)
# admin.site.register(ELZxgg, ELZxggAdmin)
# admin.site.register(ELSxgg, ELSxggAdmin)
# admin.site.register(ELFygg, ELFyggAdmin)
# admin.site.register(ELWdhmd, ELWdhmdAdmin)
# admin.site.register(ELAjlc, ELAjlcAdmin)
# admin.site.register(ELbgt, ELbgtAdmin)
# admin.site.register(ELEpbcf, ELEpbcfAdmin)
# admin.site.register(ELLawCredit, ELLawCreditAdmin)
# admin.site.register(ELAbstract, ELAbstractAdmin)
